<?php

class Setting extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Category the static model class
     */
    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return '{{setting}}';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('key,value,language', 'required'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        return array(
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'id' => 'ID',
            'name' => 'Thuộc tính',
            'value' => 'Giá trị',
            'language' => 'Ngôn ngữ',
            'rank' => 'Vị trí'
        );
    }

    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria();
        $criteria->compare('rank', 0);
        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
            'pagination' => FALSE,
            'sort' => array(
                'defaultOrder' => 'field ASC'
            ),
        ));
    }

}